package com.od.controller;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.od.service.ContactService;

@Controller
@CrossOrigin
@RequestMapping("contact")
public class ContactController {
    @Autowired
    private ContactService contactService;

    @PostMapping("allContact")
    @ResponseBody
    public List<Map<String, Object>> requestMethodName(@RequestBody Map<String, Object> userData) {
        String id = userData.get("id").toString();
        String userType = userData.get("userType").toString();
        System.out.println(id + userType);
        if ("求职者登录".equals(userType)) {
            return contactService.getContactBySeeker(id);
        }
        return contactService.getContactByEnterprise(id);
    }

    @PostMapping("contactCount")
    @ResponseBody
    public Integer postMethodName(@RequestBody Map<String, Object> userData) {
        String id = userData.get("id").toString();
        String userType = userData.get("userType").toString();
        if ("求职者登录".equals(userType)) {
            return contactService.getContactCountBySeeker(id);
        }
        return contactService.getContactCountByEnterprise(id);
    }

}
